<script charset="utf-8" src="<?=base_url()?>resource/plugins/kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="<?=base_url()?>resource/plugins/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript" src="<?=base_url()?>resource/plugins/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
//表单验证
function product_submit() {
    if(!isempty('maintain_id','维修单不能为空'))return false;
	//品牌
	if($("#brandId").val() == ''){
		alert('请选择产品品牌');
		return false;
	}
    if($("#brandId").val() == 37 && $("input[name=other_brand_name]").val() == ''){
        alert('请输入其他品牌名称');
        return false;
    }
    if(!isempty('product_model','品牌型号不能为空'))return false;
    if($("input[name=product_quantity]").val() <= 0){
        alert('产品数量必须大于0');
        return false;
    }
    /*
    var zbtype = $("input[name='is_guarantee']:checked").val();
    if(!zbtype){
        alert('请选择质保类型');
        return false;
    }
    */
    var miaoshu = $("input[name='is_description']:checked").val();
    if(!miaoshu){
        alert('请选择描述是否一致');
        return false;
    }
    var waiguang = $("input[name='damage_id']:checked").val();
    if(!waiguang){
        alert('请选择外观状况');
        return false;
    }
    var fujian = $("#fujianListId :checkbox:checked");
    if(fujian.length<=0){
        alert('请选择附件');
        return false;
    }
    var guzhang = $("#guzhangListId :checkbox:checked");
    if(guzhang.length<=0){
        alert('请选择故障');
        return false;
    }
	return true;
}

//其他品牌
function otherBrand(brand_id){
    if(brand_id && brand_id == 37){
        $("#otherBrandId").show();
    }else{
        $("#otherBrandId").hide();
    }
}

KindEditor.ready(function(K) {
    window.editor = K.create('textarea',{
        resizeType : 1,
        allowPreviewEmoticons : false,
        allowImageUpload : true,
        width : '800px;',
        Height : '250px',
        items : [
            'forecolor', 'hilitecolor','formatblock','bold','|', 'image', 'link']
    });
});

</script>


<!--top结束-->
<div class="mian">
	<div class="mian1">
		<div class="mian2">
            <!--left start-->
            <?php $this->load->view('defaults/common/left');?>
            <!--left end-->
			<!--right start-->
			<div class="right">
                <!--breadcrumb start-->
                <div class="righta"><?=$this->breadcrumb->generateHTML();?> </div>
                <!--breadcrumb end-->
				<!-- contents start -->
				<div id="contents">
					<div id="contents_container">
					<form action="<?=blang_url('products/product/'.$post_type)?>" method="post" name="productForm" onsubmit="return product_submit()" autocomplete="off" >
						<table cellpadding="0" cellspacing="0" id="table_forms" border="1">
						    <tr>
						      <th class="forms_left"><?=lang('order_wxdh')?>:</td>
						      <td>
                                  <span style="color: blue;font-size: 16px;"><?=$productFirst['maintain_id']?></span>
                                  <input type="hidden" name="maintain_id" value="<?=$productFirst['maintain_id']?>" readonly />
                              </td>
						    </tr>
						    <tr>
						      <th class="forms_left"><span>*</span><?=lang('product_sspp')?>:</td>
						      <td>
                                  <select name="brand_id" id="brandId" onchange="otherBrand(this.value)">
                                      <option value="" >--<?=lang('public_qxz')?>--</option>
                                      <?php foreach ($brandList as $rs):?>
                                          <option value="<?=$rs['brand_id']?>" <?=$optBrand[$rs['brand_id']]?> >
                                              <?=$rs['brand_name']?>
                                          </option>
                                      <?php endforeach;?>
                                  </select>&nbsp;&nbsp;&nbsp;
                                  <span id="otherBrandId" style="display: none;">
                                      <?=lang('product_qtpp')?>：
                                      <input type="text" name="other_brand_name" value="<?=$productFirst['other_brand_name']?>" placeholder="请输入品牌名称" />
                                  </span>
                              </td>
						    </tr>
						    <tr>
						      <th class="forms_left"><span>*</span><?=lang('product_cpxh')?>:</td>
						      <td><input type="text" name="product_model" value="<?=$productFirst['product_model']?>" /></td>
						    </tr>
                            <tr>
                                <th class="forms_left"><span>*</span><?=lang('product_wlsl')?>:</td>
                                <td>
                                    <input type="text" name="product_quantity" value="<?=$productFirst['product_quantity']?$productFirst['product_quantity']:1?>" onkeyup="value=value.replace(/[^\d]/g,'')" />
                                    &nbsp;&nbsp; default value (1)
                                </td>
                            </tr>
                            <tr>
                                <th class="forms_left">sku:</td>
                                <td><input type="text" name="sku" value="<?=$productFirst['sku']?>" /></td>
                            </tr>
                            <tr>
                                <th class="forms_left">IMEI:</td>
                                <td><input type="text" name="imei" value="<?=$productFirst['imei']?>" /></td>
                            </tr>
                            <tr>
                                <th class="forms_left"><span class="sort_params0">*</span><?=lang('product_zbtype')?>:</td>
                                <td>
                                    <input type="radio" name="is_guarantee" value="0"  <?=$ckdsfzb[0]?> />品牌保内 &nbsp;
                                    <input type="radio" name="is_guarantee" value="1" <?=$ckdsfzb[1]?> />保内
                                    <input type="radio" name="is_guarantee" value="2" <?=$ckdsfzb[2]?> />保外
                                </td>
                            </tr>
                            <tr>
                                <th class="forms_left"><span>*</span><?=lang('product_sffx')?>:</td>
                                <td>
                                    <input type="radio" name="is_refurbishment" value="0"  <?=$ckdsffx[0]?> />No &nbsp;
                                    <input type="radio" name="is_refurbishment" value="1" <?=$ckdsffx[1]?> />Yes
                                </td>
                            </tr>
                            <tr>
                                <th class="forms_left"><span>*</span><?=lang('product_mssfyz')?>:</td>
                                <td>
                                    <input type="radio" name="is_description" value="0"  <?=$ckdmssfyz[0]?> />No &nbsp;
                                    <input type="radio" name="is_description" value="1" <?=$ckdmssfyz[1]?> />Yes
                                </td>
                            </tr>
                            <tr>
                                <th class="forms_left"><span>*</span><?=lang('product_wgzk')?>:</td>
                                <td>
                                    <?php foreach ($damageList as $rs):?>
                                        <input type="radio" name="damage_id" value="<?=$rs['damage_id']?>" <?=$ckdwgzk[$rs['damage_id']]?> /><?=$rs['damage_name']?>&nbsp;&nbsp;
                                    <?php endforeach;?>
                                </td>
                            </tr>
                            <tr>
                                <th class="forms_left"><span>*</span><?=lang('product_sjfj')?>:</td>
                                <td>
                                    <div id="fujianListId">
                                    <?php foreach ($fujianList as $rs):?>
                                        <input type="checkbox" name="attachment_id[]" value="<?=$rs['attachment_id']?>" <?=$ckdfujian[$rs['attachment_id']]?>  />
                                        <?=$rs['attachment_name']?>&nbsp;&nbsp;
                                    <?php endforeach;?>
                                    &nbsp;&nbsp;&nbsp;<?=lang('product_qtfj')?>：
                                    <input type="text" name="other_fujian_name" value="" placeholder="<?=lang('product_gkfh')?>" /> &nbsp; 如:nameA;nameB;nameC
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <th class="forms_left"><span>*</span><?=lang('product_gz')?>:</td>
                                <td >
                                    <div id="guzhangListId">
                                        <table>
                                        <?php foreach ($guzhangList as $key=>$rs):?>
                                            <?php if(($key%5)==0){?>
                                                <tr>
                                            <?php }?>
                                            <td>
                                            <input type="checkbox" name="fault_id[]" value="<?=$rs['fault_id']?>" <?=$ckdguzhang[$rs['fault_id']]?> />
                                            <?=$rs['fault_name']?>
                                            </td>
                                            <?php if(($key%5)==4){?>
                                                </tr>
                                            <?php } ?>
                                        <?php endforeach;?>
                                        </table>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <th><?=lang('product_khbz')?>:</th>
                                <td><textarea class="editor_id" name="remark_customer" ><?=$productFirst['remark_customer']?></textarea></td>
                            </tr>
                            <tr>
                                <th><?=lang('product_zwbzkf')?>:</th>
                                <td><textarea class="editor_id" name="remark_cn"  ><?=$productFirst['remark_cn']?></textarea></td>
                            </tr>
                            <tr>
                                <th><?=lang('product_ywbzkf')?>:</th>
                                <td><textarea class="editor_id" name="remark_en"  ><?=$productFirst['remark_en']?></textarea></td>
                            </tr>

						    <tr>
						      <td align="center" colspan="2" class="sub_padding_right">
                                <input type="hidden" name="id" value="<?=$productFirst['product_id']?>" />
								<input type="submit" value="<?=lang('public_tj')?>" name="submits" style="margin-right: 20px;width: 150px; height: 30px;"/>
						      </td>
						    </tr>
					   </table>
					</form>
				   </div>
				</div>
				<!-- contents end -->
			</div>
			<!--right end-->
		</div>
	</div>
</div>

